package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/insurance"
	"github.com/streadway/amqp"
	"strconv"
)

// 将卡包信息加入出单任务
// @author liyang<654516092@qq.com>
// @date  2020/8/3 11:19
func main() {
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("insurance.log.insuranceToTask"))
	//rpc
	rpcInsurance := new(insurance.TaskPolicy).Init()
	defer rpcInsurance.Close()
	//\\rpc
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("insurance.queue.insuranceToTask"), func(msg amqp.Delivery) {
		relationId, _ := strconv.Atoi(string(msg.Body))
		var reply bool
		if err := rpcInsurance.PushRelationIdToTask(context.Background(), &relationId, &reply); err != nil {
			utils.Logerr.Printf("PushRelationIdToTask err:%v, taskId:%v", err, relationId)
		}
	})
	if err != nil {
		utils.Logerr.Printf("rabbitmq connect err:%v", err)
	}
}
